import React, { useCallback, useMemo, useState, createContext } from 'react'
import Child1 from './components/Child1'
import {Provider} from './context/context'



const App = () => {
  const [title,setTitle] = useState('我是标题')
  const [count,setCount] = useState(0)
  
  return (
    <Provider value={{
      title,
      setTitle,
      count,
      setCount
    }}>
      <div>
        <h2>{title}</h2>
        <input type="text" value={title} onChange={e=>setTitle(e.target.value)}/>
        <button onClick={() => setCount(count + 1)}>{count}</button>
        <hr />

        {title.length > 0 && <Child1 title={title}/>}

      </div>
    </Provider>

  )




}

export default App

